(function (win) {
  let doc = win.document;
  let docEl = doc.documentElement;
  let metaEI = doc.querySelector('meta[name="viewport"]');
   metaEI.setAttribute('content','initial-scale=1,maximum-scale=1, minimum-scale=1, user-scalable=no')
  // let dprb= win.devicePixelRatio
  function refreshRem() {
    let _width = docEl.getBoundingClientRect().width;
    let ua = navigator.userAgent.toLocaleLowerCase();
    if (!/ipad/.test(ua)) {
      if (_width > 750) {
        _width = 750;
      }
      docEl.style.fontSize = _width / 10 + 'px';
    }
  }
  // refreshRem()
  // let setDomFontSizeDebounce = _.debounce(refreshRem, 400) //做个防抖
  // window.addEventListener('resize', setDomFontSizeDebounce);
  let tid;
  win.addEventListener(
    'resize',
    function () {
      clearTimeout(tid);
      tid = setTimeout(refreshRem, 300);
    },
    false
  );
  win.addEventListener(
    'pageshow',
    function (e) {
      console.log(e.persisted);
      if (e.persisted) {
        clearTimeout(tid);
        tid = setTimeout(refreshRem, 300);
      }
    },
    false
  );
})(window);
